#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
int main()
{
	ll t;
	cin >> t;
	while(t--)
	{
		int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
		int t = a*b*c;
		int x = t*d*e, y = t*d*(d-1)/2;
		cout << x+y << endl;
	}
}
